﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
namespace StudentSDataBase
{
    public class Dbhelper
    {
        private static readonly string ConnSql = "server=.;database=TaskDb;uid=sa;pwd=123456";

        public static DataTable dataTable(string sql)
        {
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sql,ConnSql);
            DataTable data = new DataTable();
            sqlDataAdapter.Fill(data);
            return data;   
        }
        public static int OrUpdateOrDelete(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(ConnSql);
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            sqlConnection.Open();
            var bt = sqlCommand.ExecuteNonQuery();
            sqlConnection.Close();
            return bt;
        }
    }
}